package BiShi.first.wangyi;

        import java.util.Arrays;
        import java.util.Comparator;
        import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        //System.out.println(helper(0,0));
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int D = sc.nextInt();
            int res = D;
            int[][] AB = new int[n][2];

            for(int i = 0 ; i < n ; i++){
                AB[i][0] = sc.nextInt();
            }
            for(int i = 0 ; i < n ; i++){
                AB[i][1] = sc.nextInt();
            }
            Arrays.sort(AB, (o1, o2) -> {
                if(o1[0]!=o2[0])
                    return o1[0]-o2[0];
                else{
                    return o1[1]-o2[1];
                }
            });

            for(int i = 0 ; i < n ; i++){
                if(D > AB[i][0]){
                    D++;
                }else{
                    D-=AB[i][1];
                }
            }
            System.out.println(D > 0 ? 0 : -D);
        }
    }

}